<template>
  <div>
    <web-link-q-r-code-form
    :initForm="initForm"
    layout="block"
    :accessUrl="accessUrl"
    @cancel="cancel"
    @submit-form="updateWebOutLink"/>
  </div>
</template>

<script>
  import WebLinkQRCodeForm from './OutWebLinkQRCodeForm'
  import { deepClone } from '@utils/m7Utils'
  export default {
    name: 'OutWebLinkQRCodeUpdate',
    data () {
      return {
        form: {
          source: '',
          url: '',
          logo: {
            name: '',
            url: ''
          },
          isQRcode: false
        }
      }
    },
    props: {
      accessUrl: String,
      initForm: {
        type: Object,
        default: () => {
          return {
            source: '',
            url: '',
            logo: {
              name: '',
              url: ''
            },
            isQRcode: false
          }
        }
      }
    },
    components: {
      WebLinkQRCodeForm
    },
    watch: {
      initForm (n, o) {
        this.form = deepClone(n)
      }
    },
    methods: {
      cancel () {
        this.$emit('cancel')
      },
      updateWebOutLink (form) {
        this.$emit('edit-success', form)
      }
    },
    beforeMount () {
      console.log('beforeMount-update')
      this.form = deepClone(this.initForm)
    }
  }
</script>